package com.wolfalpha.utron.activity;

import android.os.Bundle;
import android.widget.GridView;

import com.wolfalpha.utron.R;
import com.wolfalpha.utron.activity.base.BaseNormalActivity;
import com.wolfalpha.utron.adapter.IdeaDirAdapter;
import com.wolfalpha.utron.ui.UIHelper;
import com.wolfalpha.utron.utils.StringUtils;

import java.util.List;

/**
 * 发布创意选择标签
 * <p/>
 * Created by luodon on 15/8/27.
 */
public class IdeaChooseDirActivity extends BaseNormalActivity {

    private GridView gridView;

    private IdeaDirAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_idea_publish_choose_dir);

        initView();
    }

    /**
     * 初始化布局
     */
    private void initView() {
        setTvTitle("发布创意");
        final List<String> data = StringUtils.getDirsValues(IdeaChooseDirActivity.this);
        gridView = (GridView) findViewById(R.id.gv_idea_dir);
        adapter = new IdeaDirAdapter(this, data, true);
        gridView.setAdapter(adapter);
        gridView.setClickable(true);

        adapter.setOnFinishedListener(new IdeaDirAdapter.OnFinishedListener() {
            @Override
            public void finish(int select) {
                Bundle bundle = new Bundle();
                int i = select + 1000 + 1;
                bundle.putInt("dir", i);
                UIHelper.showActivity(IdeaChooseDirActivity.this, IdeaPublishActivity.class, bundle);
                IdeaChooseDirActivity.this.finish();
            }
        });
    }
}
